#include "TestSuite.h"
#include "TestCase.h"
#include "ImageStore.h"
#include <wx/treectrl.h>
#include <list>

using std::list;

class TestSuiteImpl
{
public:
	list<TestCase*> testCases;
	wxString name;
};

TestSuite::TestSuite(const wxString& name)
{
	impl = new TestSuiteImpl();
	impl->name = name;
}

TestSuite::~TestSuite()
{
	delete impl;
}

void TestSuite::Add(TestCase* testCase)
{
	impl->testCases.push_back(testCase);
}

void TestSuite::Run()
{
	list<TestCase*>::iterator iter, end;
	iter = impl->testCases.begin();
	end = impl->testCases.end();

	while (iter != end)
	{
		(*iter)->Run();
		iter++;
	}
}

void TestSuite::Draw(wxTreeCtrl& tree, wxTreeItemId& parent)
{
	list<TestCase*>::iterator iter, end;
	iter = impl->testCases.begin();
	end = impl->testCases.end();

	wxTreeItemId id = 
		tree.AppendItem(
			parent, impl->name, 
			ImageStore::GetTestExplorerImageIndex(_T("tc_uninit.png")));
	
	while (iter != end)
	{
		(*iter)->Draw(tree, id);
		iter++;
	}
}